You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-25, 25' at line 1
query=SELECT products.*, min(products_atts.price) as pricefrom, count(products_atts.product_id) as attcount, products_images.filename as thefile from prodcat_weight inner join products on products.prod_id=prodcat_weight.prod_id left join products_atts on products.id=products_atts.product_id left join products_images on products.prod_id=products_images.prod_id and products_images.firstimg=1 WHERE prodcat_weight.cat_id in (41,39,85,86,87,88,89,90,37,78,80,81,79,36,70,73,75,71,72,76,74,77,40,91,92,34,47,94,46,44,50,43,54,51,125,52,53,49,56,55,48,57,127,45,93,38,82,84,83,42,96,95,35,68,58,62,67,60,63,123,64,66,61,65,59,69,124,5) and prodcat_weight.hidden='0' group by products.id order by prodcat_weight.weight ASC, id desc LIMIT -25, 25